<?php
class db{
	var $Record=array();var $Link_ID=0;var $Query_ID=0;
	function db($db){	
		if(!$this->Link_ID){
			$this->Link_ID=mysql_connect('localhost','root','qwe12311');
			mysql_select_db($db,$this->Link_ID);
		}
		mysql_query("set names 'utf8'",$this->Link_ID);
	}
	function insert_id(){return mysql_insert_id($this->Link_ID);}
	function query($sql){
		$this->Query_ID=mysql_query($sql);
		return $this->Query_ID?$this->Query_ID:0;
	}
	function next_record() {
		if(!$this->Query_ID) {return 0;}
		$this->Record=mysql_fetch_array($this->Query_ID);
		return is_array($this->Record)?$this->Record:0;
	}
	function query_first($sql){  
		if(!$this->query($sql)) {return 0;}
		$this->Record=mysql_fetch_array($this->Query_ID);
		return $this->Record;
	}
	function num_rows() {return mysql_num_rows($this->Query_ID);}
	function num_affected_rows() {return mysql_affected_rows();}
	function f($field) {return $this->Record[$field];}
}
	$db=new db('daili');
?>